package com.hzhr.iot.collect.dao.helper;

import com.hzhr.iot.collect.dao.CachedCommandDao;
import com.hzhr.iot.collect.entity.CachedCommandEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Service
public class CachedCommandDaoHelper {
	@Autowired
	CachedCommandDao cachedCommandDao;

	public List<CachedCommandEntity> getListBySendTime(String sendTime) {
		return cachedCommandDao.selectListBySendTime(sendTime);
	}

	public List<CachedCommandEntity> getListByDeviceId(String deviceId) {
		return cachedCommandDao.selectListByDeviceId(deviceId);
	}

	public void postBySendTime(CachedCommandEntity commandEntity, String sendTime, long expireTime, TimeUnit timeUnit) {
		cachedCommandDao.insertBySendTime(commandEntity, sendTime, expireTime, timeUnit);
	}
	
	public void postListBySendTime(List<CachedCommandEntity> commandEntityList, String sendTime, long expireTime, TimeUnit timeUnit) {
		cachedCommandDao.insertListBySendTime(commandEntityList, sendTime, expireTime, timeUnit);
	}

	public void postByDeviceId(CachedCommandEntity commandEntity, String deviceId, long expireTime,
			TimeUnit timeUnit) {
		cachedCommandDao.insertByDeviceId(commandEntity, deviceId, expireTime, timeUnit);
	}

	public void postBySendTime(CachedCommandEntity commandEntity, String sendTime) {
		cachedCommandDao.insertBySendTime(commandEntity, sendTime);
	}

	public void postByDeviceId(CachedCommandEntity commandEntity, String deviceId) {
		cachedCommandDao.insertByDeviceId(commandEntity, deviceId);
	}

	public void deleteByDeviceIdByMessageId(String deviceId, String messageId) {
		cachedCommandDao.deleteByDeviceIdByMessageId(deviceId, messageId);
	}

	public void setByDeviceId(List<CachedCommandEntity> commandEntityList, String deviceId) {
		cachedCommandDao.setByDeviceId(commandEntityList, deviceId);
	}
}




